@extends('admin.layouts')
@section('style')
    <style>
        #iconfont{font-size:24px;margin:0 10px;}
    </style>
@endsection
@section('main')
    <div class="add-subcat layui-layer-wrap" style="display: block;">
        <form id="form1" class="layui-form layui-form-pane" action="{{url('admin/permissionedit')}}">
            {{csrf_field()}}
            <input type="hidden" name="id" value="{{$data->id}}">
            <div class="layui-form-item">
                <label class="layui-form-label">{{trans('config.permission')}}</label>
                <div class="layui-input-inline">
                    <select name="pid">
                        <option value="0">{{trans('config.astop')}}</option>
                        @foreach($permission as $v)
                            <option value="{{$v->id}}" @if($data->pid==$v->id) selected="selected" @endif @if(in_array($v->id,$ids)) disabled="disabled" @endif>{{$v->_cate_name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{trans('config.display_name')}}</label>
                <div class="layui-input-inline">
                    <input type="text" name="display_name" value="{{$data->display_name}}" placeholder="{{trans('config.input_display_name')}}" autocomplete="off" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{trans('config.permission')}}</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" jq-verify="required" value="{{$data->name}}" jq-error="{{trans('config.vali_required')}}" placeholder="{{trans('config.input_permission')}}" autocomplete="off" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{{trans('config.url')}}</label>
                <div class="layui-input-inline">
                    <input type="text" name="url" placeholder="{{trans('config.input_url')}}" value="{{$data->url}}" autocomplete="off" class="layui-input ">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">{{trans('config.iconfont')}}</label>
                <div class="layui-input-inline">
                    <i class="iconfont" id="iconfont">{{$data->iconfont}}</i>
                    <input type="hidden" name="iconfont" value="{{htmlspecialchars($data->iconfont)}}"/>
                    <button type="button" class="layui-btn modal-iframe" id="btn-icon">{{trans('config.choose')}}</button>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">{{trans('config.sort')}}</label>
                <div class="layui-input-inline">
                    <input type="text" name="listsort" value="{{$data->listsort}}" placeholder="{{trans('config.input_sort')}}" autocomplete="off" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-inline" style="width:100%">
                    <textarea type="text" name="description" placeholder="{{trans('config.text_description')}}" autocomplete="off" class="layui-textarea">{{$data->description}}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" jq-submit jq-filter="submit">{{trans('config.btn_submit')}}</button>
                </div>
            </div>
        </form>
    </div>
@endsection

@section('script')

<script>
    layui.use(['jquery','simpleform','layer'],function(){
        var $= layui.jquery;
        var index = parent.layer.getFrameIndex(window.name);
        $('#btn-icon').click(function(){
            parent.layer.open({
                type: 2,
                title:"{{trans('config.choose')}} {{trans('config.iconfont')}}",
                area: ['600px', '600px'],
                fixed: true, //不固定
                maxmin: false,
                content: "{{url('admin/iconfont')}}?index="+index,
            });
        })
    });
</script>
@endsection